<template>
  <div>
    <img :src="item.url" alt="" width="100%" />
    <h1>{{ item.title }}</h1>
    <p>{{ item.desc }}</p>

    <van-goods-action>
      <van-goods-action-button
        type="danger"
        text="加入书架"
        @click="$store.commit('ADD_BOOK', item)"
      />
       <van-goods-action-button
        type="danger"
        text="立即阅读"
      />
    </van-goods-action>
  </div>
</template>


<script>
import request from "@/utils";

export default {
  created() {
    this.getDetail();
  },
  methods: {
    getDetail() {
      const { id } = this.$route.params;
      request.post("/api/detail", { id }).then(resp => {
        this.item = resp.data.data;
      });
    }
  },
  data() {
    return {
      item: {}
    };
  }
};
</script>